﻿using System.Collections.Generic;
using TSharp.Core.Osgi.Internal;
using System;

namespace TSharp.Core.Services
{
    /// <summary>
    /// 模板解析服务外观
    /// <para>2010/12/29</para>
    /// 	<para>TANGJINGBO</para>
    /// 	<para>tangjingbo</para>
    /// </summary>
    public interface ITemplateParserService : IHideObjectMembers
    {
        #region Properties

        /// <summary>
        /// Gets the collection of namespaces.
        /// </summary>
        ISet<string> Namespaces { get; }

        #endregion

        #region Methods


        /// <summary>
        /// Compiles the type.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="templateType">Type of the template.</param>
        /// <param name="modelType">Type of the model.</param>
        /// <returns></returns>
        Type CompileType(string template, string name, Type templateBaseType, Type modelType);

        /// <summary>
        /// Parses the given template and returns the result.
        /// </summary>
        /// <typeparam name="T">The model type.</typeparam>
        /// <param name="template">The template to parse.</param>
        /// <param name="model">The model.</param>
        /// <param name="name">[Optional] The name of the template. This is used to cache the template.</param>
        /// <returns>The string result of the parsed template.</returns>
        string Parse<T>(string template, string name, T model, Type templateBaseType);

        /// <summary>
        /// Runs the template with the specified name.
        /// </summary>
        /// <param name="name">The name of the template to run.</param>
        /// <returns>The result of the template.</returns>
        string Run(string name);

        /// <summary>
        /// Runs the template with the specified name.
        /// </summary>
        /// <typeparam name="T">The model type.</typeparam>
        /// <param name="model">The model.</param>
        /// <param name="name">The name of the template to run.</param>
        /// <returns>The result of the template.</returns>
        string Run<T>(T model, string name);

        #endregion
    }
}